package io.renren.modules.sys.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.DormRepairDao;
import io.renren.modules.sys.entity.DormRepairEntity;
import io.renren.modules.sys.service.DormRepairService;


@Service("dormRepairService")
public class DormRepairServiceImpl extends ServiceImpl<DormRepairDao, DormRepairEntity> implements DormRepairService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<DormRepairEntity> wrapper = new QueryWrapper<>();
        String key = (String)params.get("key");
        wrapper.like(StringUtils.isNotBlank(key), "reason",key);

        if(params.get("dormId")!=null && !params.get("dormId").equals("")){
            wrapper.like("dorm_id", Integer.parseInt((String)params.get("dormId")));
        }
        IPage<DormRepairEntity> page = this.page(
                new Query<DormRepairEntity>().getPage(params),
              wrapper
        );
        return new PageUtils(page);
    }

}